package com.bj58.mis.apm.server.core.util;

import java.util.Arrays;
import java.util.List;

/**
 * @Author: wangxw
 * @Date: 2018/10/16 9:54
 */
public class TimesUtil {

    private static List<String> units = Arrays.asList("h", "m", "s");

    public static String formatTimes(Long l) {
        if(l == null) {
            return null;
        }
        StringBuilder sb = new StringBuilder();
        int i = units.size() - 1;
        while(l > 0 && i >= 0){
            if(l % 60 > 0) {
                sb.insert(0, (l % 60) + units.get(i));
            }
            l = l/60;
            i--;
        }
        return sb.toString();
    }

}